/* Created on Jun 6, 2007 */
/**
 * 
 */
package com.xbang.core.dao.search.component;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author dev.zhang
 */
public class SearchContainer implements Serializable {

    private static final long serialVersionUID = -2161210185148131343L;

    private Map<String, Object> map = new HashMap<String, Object>();

    /**
     * 
     */
    public SearchContainer() {
    }

    /**
     * @return Returns true if the map is empty
     */
    public boolean isEmpty() {
        return this.map.isEmpty();
    }

    /**
     * Get the context of the Value Stack
     * 
     * @return
     */
    public Map<String, Object> getContext() {
        return map;
    }

    /**
     * Get the parameter from request key
     * 
     * @param key
     * @return
     */
    public Object get(String key) {
        return map.get(key);
    }

    /**
     * 
     * @param key
     * @return
     */
    public boolean contains(String key) {
        return this.map.containsKey(key);
    }

    /**
     * Set the parameter for request key
     * 
     * @param key
     * @param className
     * @throws ClassNotFoundException
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public void set(String key, Class<?> persistentClass) {
        try {
            map.put(key, persistentClass.newInstance());
        } catch (Exception e) {
            map.put(key, null);
        }
    }

}
